package com.yunxi.job;

import com.yunxi.baseDataToHub.service.iam.IamDubboService;
import com.yunxi.eai.service.iam.IamService;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;

/**
 * Created by Administrator on 2019/8/6.
 */
@DisallowConcurrentExecution
@Component
public class StaffDataJob implements BaseJob{
    protected static final Logger LOGGER = LoggerFactory.getLogger(StaffDataJob.class);
    @Autowired
    private IamDubboService iamDubboServiceImpl;

    public StaffDataJob() {

    }
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar c1 = new GregorianCalendar();
        c1.set(Calendar.HOUR_OF_DAY, 0);
        c1.set(Calendar.MINUTE, 0);
        c1.set(Calendar.SECOND, 0);
        String beginTime=sdf.format(c1.getTime());
        Calendar c2 = new GregorianCalendar();
        c2.set(Calendar.HOUR_OF_DAY, 23);
        c2.set(Calendar.MINUTE, 59);
        c2.set(Calendar.SECOND, 59);
        String endTime=sdf.format(c2.getTime());
        List list=new ArrayList();
        list.add("S0100001C");
        list.add("S0100002C");
        list.add("S0100003C");
        for (int i = 0; i < list.size(); i++) {
            String serviceName = (String) list.get(i);
            try {
                iamDubboServiceImpl.findDataByConditional(serviceName, beginTime, endTime);
            } catch (Exception e) {
                LOGGER.error(e.getMessage(),e);
            }
        }
        try {
            iamDubboServiceImpl.findUpsUserByConditional("S0100002C","UPSPARTS-OEM", beginTime, endTime);
        } catch (Exception e) {
            LOGGER.error(e.getMessage(),e);
        }
    }
}
